
#ifndef TOTPMANAGER_H
#define TOTPMANAGER_H
#include <vector>
#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QByteArray>
#include <botan/cipher_mode.h>

#include "totp.h"
#include <utils/enums.h>

namespace totp {
class TOTPManager : public QObject {
	Q_OBJECT
	public:
	TOTPManager(const std::filesystem::path& filepath, utils::CipherAlgorithm algorithm,const Botan::SymmetricKey& encryptionKey, QObject* parent = nullptr);

	const std::vector<TOTP>& getTOTPs() const;

	void saveTOTPs();

	void loadTOTPs();

public slots:
	void addTOTP(const TOTP& totp);

	void deleteTOTP(const TOTP& totp);

private:
	QByteArray encrypt(const QByteArray& plaintext);

	QByteArray decrypt(const QByteArray& ciphertext);

	QString filepath;
	Botan::SymmetricKey encryptionKey;
	std::vector<TOTP> totps;
	std::string algos;
};
}

#endif //TOTPMANAGER_H
